<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
            label-width="68px">
            <el-form-item label="发货日期" prop="ddDate">
                <el-date-picker clearable v-model="queryParams.ddDate" type="date" value-format="yyyy-MM-dd"
                    placeholder="请选择发货日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="需求日期" prop="subDate">
                <el-date-picker clearable v-model="queryParams.subDate" type="date" value-format="yyyy-MM-dd"
                    placeholder="请选择需求日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="镀锌厂名称" prop="supplierName">
                <el-input v-model="queryParams.supplierName" placeholder="请输入镀锌厂名称" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="镀锌发货过磅单" prop="bangdan">
                <el-input v-model="queryParams.bangdan" placeholder="请输入镀锌发货过磅单" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="镀锌发货清单" prop="qingdan">
                <el-input v-model="queryParams.qingdan" placeholder="请输入镀锌发货清单" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="镀锌回厂榜单" prop="bangdanhui">
                <el-input v-model="queryParams.bangdanhui" placeholder="请输入镀锌回厂榜单" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="镀锌回厂清单" prop="qingdanhui">
                <el-input v-model="queryParams.qingdanhui" placeholder="请输入镀锌回厂清单" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="回厂日期" prop="hcDate">
                <el-date-picker clearable v-model="queryParams.hcDate" type="date" value-format="yyyy-MM-dd"
                    placeholder="请选择回厂日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="产品名称" prop="name">
                <el-input v-model="queryParams.name" placeholder="请输入产品名称" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="产品型号" prop="model">
                <el-input v-model="queryParams.model" placeholder="请输入产品型号" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                         v-hasPermi="['develop:LvDuxindetail:add']">新增</el-button>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
              <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                         v-hasPermi="['develop:LvDuxindetail:export']">导出</el-button>
            </el-form-item>
        </el-form>

        <!--<el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
            </el-col>
            <el-col :span="1.5">
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>-->

        <el-table border v-loading="loading" :data="dataList" @selection-change="handleSelectionChange" ref="table"
            :max-height="tableMaxHeight">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="备注" align="center" prop="remark" />
            <!-- <el-table-column label="发货日期" align="center" prop="ddDate" width="180">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.ddDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
                </template>
            </el-table-column>
            <el-table-column label="需求日期" align="center" prop="subDate" width="180">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.subDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
                </template>
            </el-table-column> -->
            <!-- <el-table-column label="订单金额" align="center" prop="money" />
            <el-table-column label="总数量" align="center" prop="counts" /> -->
            <el-table-column label="总毛重" align="center" prop="dunwei" />
            <el-table-column label="总皮重" align="center" prop="pizhong" />
            <el-table-column label="总净重" align="center" prop="jingzhong" />
            <!-- <el-table-column label="镀锌厂名称" align="center" prop="supplierName" />
            <el-table-column label="镀锌发货过磅单" align="center" prop="bangdan" />
            <el-table-column label="镀锌发货清单" align="center" prop="qingdan" />
            <el-table-column label="镀锌回厂榜单" align="center" prop="bangdanhui" />
            <el-table-column label="镀锌回厂清单" align="center" prop="qingdanhui" />
            <el-table-column label="回厂日期" align="center" prop="hcDate" width="180">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.hcDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
                </template>
            </el-table-column> -->
            <el-table-column label="回厂总数量" align="center" prop="hcCount" />
            <el-table-column label="回厂毛重" align="center" prop="hcDunwei" />
            <el-table-column label="回厂皮重" align="center" prop="hcPizhong" />
            <el-table-column label="回厂净重" align="center" prop="hcJingzhong" />
            <!-- <el-table-column label="负责人及电话" align="center" prop="fuzeren" />
            <el-table-column label="镀锌厂人及电话" align="center" prop="duxinren" /> -->
            <el-table-column label="产品名称" align="center" prop="name" />
            <el-table-column label="产品型号" align="center" prop="model" />
            <el-table-column label="剩余回厂数量" align="center" prop="shengyuCount" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                        v-hasPermi="['develop:LvDuxindetail:edit']">修改</el-button>
                    <el-popconfirm :title="`确认删除当前数据项？`" @confirm="handleDelete(scope.row)" style="margin-left: 10px;">
                        <el-button slot="reference" size="mini" type="text" icon="el-icon-delete"
                            v-hasPermi="['develop:LvDuxindetail:remove']">删除</el-button>
                    </el-popconfirm>
                </template>
            </el-table-column>
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />

        <lvDuxindetail-form ref="form" @ok="getList"></lvDuxindetail-form>
    </div>
</template>

<script>
import { deleteAction, getAction } from '@/api/manage'
import LvDuxindetailForm from '@/views/develop/lvDuxindetail/module/LvDuxindetailForm'

export default {
    name: "LvDuxindetailList",
    components: {
        LvDuxindetailForm,
    },
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 镀锌单明细表格数据
            dataList: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                ddDate: null,
                subDate: null,
                money: null,
                counts: null,
                dunwei: null,
                pizhong: null,
                jingzhong: null,
                supplierName: null,
                bangdan: null,
                qingdan: null,
                bangdanhui: null,
                qingdanhui: null,
                status: null,
                type: null,
                hcDate: null,
                hcCount: null,
                hcDunwei: null,
                hcPizhong: null,
                hcJingzhong: null,
                fuzeren: null,
                duxinren: null,
                name: null,
                model: null,
                shengyuCount: null
            },
            url: {
                list: '/lvDuxindetail/lvDuxindetail/list',
                remove: '/lvDuxindetail/lvDuxindetail/',
                export: '/lvDuxindetail/lvDuxindetail/export',
            },
            tableMaxHeight: window.innerHeight - 320,
        };
    },
    created() {
        this.getList();
        window.addEventListener('resize', this.getTableHeight);
    },
    destroyed() {
        window.removeEventListener('resize', this.getTableHeight)
    },
    methods: {
        /** 查询镀锌单明细列表 */
        getList() {
            this.loading = true;
            getAction(this.url.list, this.queryParams).then(response => {
                this.dataList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        getTableHeight() {
            this.tableHeight = window.innerHeight - 320
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.$refs.form.handleAdd();
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.$refs.form.handleUpdate(row);
        },
        /** 删除按钮操作 */
        handleDelete(row) {
            const ids = row.id || this.ids;
            deleteAction(this.url.remove, ids).then(response => {
                this.getList();
                this.$modal.msgSuccess("删除成功");
            }).catch(() => { });
        },
        /** 导出按钮操作 */
        handleExport() {
            this.download(this.url.export, {
                ...this.queryParams
            }, `lvDuxindetail_${new Date().getTime()}.xlsx`)
        },
    }
};
</script>
